<template>
  <div>
    <p>newton(2.0, 1.0) = {{ newton(2.0, 1.0) }}</p>
    <p>newton(3.0, 1.0) = {{ newton(3.0, 1.0) }}</p>
    <p>newton(4.0, 6.0) = {{ newton(4.0, 6.0) }}</p>
    <p>newton(0.25, 10) = {{ newton(0.25, 10.0) }}</p>
  </div>
</template>

<script>

export default {
  name: "Newton",
  methods: {
    newton(t, g) {
      while (Math.abs(g * g - t) > 0.001) {
        g = g - (g * g - t) / (2 * g);
      }
      return g;
    }
  }
}
</script>

<style scoped>

</style>